﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace OptoMeasure.Views
{
    /// <summary>
    /// DevicesConnectView.xaml 的交互逻辑
    /// </summary>
    public partial class DevicesConnectView : UserControl
    {
        private bool _isCameraLoaded = false;
        private DevicesConnectViewModel _vm;
        public DevicesConnectView(DevicesConnectViewModel vm )
        {
            InitializeComponent();

            _vm = vm;
            DataContext = _vm;
            this.Loaded+= OnLoaded;
        }


        private async void OnLoaded(object sender, RoutedEventArgs e)
        {
            if(_isCameraLoaded) return;

            await Task.Delay(300);
            foreach (var model in _vm.CameraList)
            {
                model.RefreshCameraIdentifierList();
            }

            _isCameraLoaded = true;
        }
    }

    
}
